/**
 * @Author Stringzhua
 * @Date 2024/11/9 20:06
 * description:
 */
import java.util.Scanner;
import java.util.Stack;

public class test01 {
    public static void main(String[] args) {
        int[] input = readInput();
        int n = input[0];
        int[] prices = new int[n];
        for (int i = 0; i < n; i++) {
            prices[i] = input[i + 1];
        }
        int m = input[n + 1];
        int[] orders = new int[m];
        for (int i = 0; i < m; i++) {
            orders[i] = input[n + 2 + i];
        }

        long[] dp = new long[30001];
        dp[0] = 1;
        for (int price : prices) {
            for (int j = 30000; j >= price; j--) {
                dp[j] += dp[j - price];
            }
        }

        for (int order : orders) {
            if (dp[order] == 0) {
                System.out.println(-1);
            } else if (dp[order] > 1) {
                System.out.println(-2);
            } else {
                Stack<Integer> resultStack = new Stack<>();
                int amount = order;
                for (int i = prices.length - 1; i >= 0 && amount > 0; i--) {
                    while (amount >= prices[i]) {
                        resultStack.push(i + 1);
                        amount -= prices[i];
                    }
                }
                while (!resultStack.isEmpty()) {
                    System.out.print(resultStack.pop() + " ");
                }
                System.out.println();
            }
        }
    }

    public static int[] readInput() {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] input = new int[n + n + 2];
        input[0] = n;
        for (int i = 0; i < n; i++) {
            input[i + 1] = scanner.nextInt();
        }
        int m = scanner.nextInt();
        input[n + 1] = m;
        for (int i = 0; i < m; i++) {
            input[n + 2 + i] = scanner.nextInt();
        }
        return input;
    }
}



